<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="css/mui.min.css">
	</head>
	
	<body id="phone">
		<!--下拉刷新容器-->
		<div id="pullrefresh" class="mui-content mui-scroll-wrapper">
			<div class="mui-scroll">
				<!--数据列表-->
				<ul class="mui-table-view mui-table-view-chevron">
					<li class="mui-table-view-cell" v-for="item in items">
						<a class="mui-navigate-right">{{item.name}}</a>
					</li>
				</ul>
			</div>
		</div>
		
		<script src="js/mui.min.js"></script>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
		<script>
			var phone = new Vue({
				el: '#phone',
				data: {
					items: []
				},
				ready: function(){
					mui.init({
						pullRefresh: {
							container: '#pullrefresh',
							down: {
								callback: this.pulldownRefresh
							},
							up: {
								contentrefresh: '正在加载...',
								callback: this.pullupRefresh
							}
						}
					});
					if (mui.os.plus) {
						mui.plusReady(function() {
							setTimeout(function() {
								mui('#pullrefresh').pullRefresh().pullupLoading();
							}, 1000);
						});
					} else {
						mui.ready(function() {
							mui('#pullrefresh').pullRefresh().pullupLoading();
						});
					}
				},
				methods: {
					// 下拉刷新具体业务实现
					pulldownRefresh: function() {
						var self = this;
						setTimeout(function() {
							for(var i=0; i < 5; i++) {
								self.items.unshift({
									name:'down'+i
								})
							}
							mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed
						}, 1500);
					},
					// 上拉加载具体业务实现
					pullupRefresh: function() {
						var self = this;
						setTimeout(function() {
							mui('#pullrefresh').pullRefresh().endPullupToRefresh(); //refresh completed
							for(var i=0; i < 15; i++) {
								self.items.push({
									name:'up'+i
								})
							}
						}, 1500);
					}
				}
			});		
		</script>
	</body>
</html>